package com.basketball.gym.pojo;

import com.baomidou.mybatisplus.annotation.IdType;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;

import java.io.Serializable;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @author 赵肖云
 * @since 2021-03-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "Order对象", description = "")
public class Orders implements Serializable {
    public interface post {
    }

    public interface topUp {
    }

    public interface pay {
    }

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "备注")
    private String comment;

    @ApiModelProperty(value = "订单状态（1为已下单，2为已支付，3为已完成，4为已取消）")
    private Integer state;

    @ApiModelProperty(value = "价格")
    @NotNull(message = "price不能为空", groups = {topUp.class})
    private Double price;

    @ApiModelProperty(value = "是否删除")
    @TableLogic
    private Integer deleted;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateAt;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createAt;

    @ApiModelProperty(value = "入场券数量")
    private Integer ticketSum;

    @ApiModelProperty(value = "预订类型（1为散客，2为包半场，3为包整场，4为充值）")
    @NotNull(message = "type不能为空", groups = {post.class})
    @Min(value = 1, message = "type只能是1，2，3")
    @Max(value = 3, message = "type只能是1，2，3")
    private Integer type;

    @ApiModelProperty(value = "预定人ID")
    private Integer userId;

    @ApiModelProperty(value = "日程ID")
    private String calendarId;

    @ApiModelProperty(value = "日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date date;

    @ApiModelProperty(value = "场地ID")
    private Integer courtId;

    @ApiModelProperty(value = "订单ID")
    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "id不能为空", groups = {pay.class})
    private Integer id;

    @ApiModelProperty(value = "订单编号")
    private String outTradeNo;

    @ApiModelProperty(value = "微信订单编号")
    private String transactionId;

    @ApiModelProperty("退款编号")
    private String outRefundNo;

    @ApiModelProperty("微信退款编号")
    private String refundId;

    @ApiModelProperty("用户")
    @TableField(exist = false)
    private User user;

    @TableField(exist = false)
    @JsonBackReference("当前页")
    @ApiModelProperty("当前页")
    private Integer current;

    @TableField(exist = false)
    @JsonBackReference("每页条数")
    @ApiModelProperty("每页条数")
    private Integer size;

    public Orders() {
    }

    public Orders(String comment, Integer state, Double price, Integer deleted, LocalDateTime updateAt, LocalDateTime createAt, Integer ticketSum, @NotNull(message = "type不能为空") @Min(value = 1, message = "type只能是1，2，3") @Max(value = 3, message = "type只能是1，2，3") Integer type, Integer userId, String calendarId, Date date, Integer courtId) {
        this.comment = comment;
        this.state = state;
        this.price = price;
        this.deleted = deleted;
        this.updateAt = updateAt;
        this.createAt = createAt;
        this.ticketSum = ticketSum;
        this.type = type;
        this.userId = userId;
        this.calendarId = calendarId;
        this.date = date;
        this.courtId = courtId;
    }
}
